﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using park.cn.linkit.epark;
using park.Common;

namespace park.System_Db
{
    public partial class Backup : System.Web.UI.Page
    {
        ServiceList ws = new ServiceList();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["m"] != null)
            {
                Response.ContentType = "application/json";
                string m = Request.Params["m"];
                string r = "{}";
                switch (m)
                {
                    case "ListDatabaseBackup":
                        r = ListDatabaseBackup();
                        break;
                    case "BackupDb":
                        r = BackupDb();
                        break;
                    case "RestoreDb":
                        r = RestoreDb();
                        break;

                }
                Response.Write(r);
                Response.End();
            }
        }

        string RestoreDb()
        {
            string order = Utils.RequestValue("order");
            string result = @"{
""success"":0 
,""msg"": ""数据库连接错误"" 
}
";
            result = ws.RestoreDb(order);
            return result;
        }

        string BackupDb()
        {
            string name = Utils.RequestValue("name");
            string result = @"{
""success"":1 
,""msg"": ""123"" 
}
";
            result = BackupDb();
            return result;
        }

        string ListDatabaseBackup()
        {
            string result = @"[
{
""order"":1
,""name"":""xxxx"" 
,""size"":""120MB""
,""time"":""2012-01-01 18:30:32""

}
]
";
            result = ws.ListDatabaseBackup();
            return result;
        }
    }
}